/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pc;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.math.BigDecimal;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author echoff <echoffmu@gmail.com>
 */
@Entity
@Table(name = "COLOR", catalog = "", schema = "EASY")
@NamedQueries({
    @NamedQuery(name = "Color.findAll", query = "SELECT c FROM Color c"),
    @NamedQuery(name = "Color.findByCid", query = "SELECT c FROM Color c WHERE c.cid = :cid"),
    @NamedQuery(name = "Color.findByColornum", query = "SELECT c FROM Color c WHERE c.colornum = :colornum"),
    @NamedQuery(name = "Color.findByColordesc", query = "SELECT c FROM Color c WHERE c.colordesc = :colordesc")})
public class Color implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    @Basic(optional = false)
    @Column(name = "CID")
    private BigDecimal cid;
    @Basic(optional = false)
    @Column(name = "COLORNUM")
    private String colornum;
    @Column(name = "COLORDESC")
    private String colordesc;
    @JoinColumn(name = "PID", referencedColumnName = "PID")
    @ManyToOne(optional = false)
    private Product pid;

    public Color() {
    }

    public Color(BigDecimal cid) {
        this.cid = cid;
    }

    public Color(BigDecimal cid, String colornum) {
        this.cid = cid;
        this.colornum = colornum;
    }

    public BigDecimal getCid() {
        return cid;
    }

    public void setCid(BigDecimal cid) {
        BigDecimal oldCid = this.cid;
        this.cid = cid;
        changeSupport.firePropertyChange("cid", oldCid, cid);
    }

    public String getColornum() {
        return colornum;
    }

    public void setColornum(String colornum) {
        String oldColornum = this.colornum;
        this.colornum = colornum;
        changeSupport.firePropertyChange("colornum", oldColornum, colornum);
    }

    public String getColordesc() {
        return colordesc;
    }

    public void setColordesc(String colordesc) {
        String oldColordesc = this.colordesc;
        this.colordesc = colordesc;
        changeSupport.firePropertyChange("colordesc", oldColordesc, colordesc);
    }

    public Product getPid() {
        return pid;
    }

    public void setPid(Product pid) {
        Product oldPid = this.pid;
        this.pid = pid;
        changeSupport.firePropertyChange("pid", oldPid, pid);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cid != null ? cid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Color)) {
            return false;
        }
        Color other = (Color) object;
        if ((this.cid == null && other.cid != null) || (this.cid != null && !this.cid.equals(other.cid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pc.Color[ cid=" + cid + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
